package com.language.data_procress.score;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import com.webservice.webservice_line;

public class data_procress_return_scores extends scores {

	public String return_score_byName(String name) {
		String path = super.getScorePATH() + "returnScoreByName/" + name;
		JSONObject jo = new webservice_line().startService_ReturnJSON(path);
		try {
			int i = Integer.parseInt(jo.toString());
			return String.valueOf(i);
		} catch (Exception e) {
			return jo.toString() + e.getMessage();
		}
	}

	public List<String> return_all_score() {
		String path = super.getScorePATH();
		JSONObject jo = new webservice_line().startService_ReturnJSON(path);
		List<String> list = new ArrayList<String>();
		try {
			JSONArray jaID = jo.getJSONArray("id");
			JSONArray jaNAME = jo.getJSONArray("name");
			JSONArray jaSCORE = jo.getJSONArray("score");

			for (int i = 0; i < jaID.length(); i++) {
				list.add(jaID.getInt(i) + ". " + jaNAME.getString(i) + " : "
						+ jaSCORE.getString(i));
			}
			return list;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}

}